package com.wkm.chainchain.pbft.common;

import org.yaml.snakeyaml.Yaml;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;

public class SimulationParameterConst {
    public static HashMap<String, Object> map = new HashMap<>();
    /**
     * 起始端口号
     */
    public static int INITIAL_PORT;
    /**
     * P2P网络中的节点数
     */
    public static int NODE_AMOUNT;
    /**
     * client消息客户端端口地址
     */
    public static int CLIENT_PORT;

    //获取yaml文件里设置的属性
    static {
        try {
            Yaml yaml = new Yaml();
            FileReader reader = new FileReader("src\\main\\resources\\const.yaml");
            BufferedReader buffer = new BufferedReader(reader);
            map = yaml.load(buffer);
            INITIAL_PORT = (int) map.get("INITIAL_PORT");
            NODE_AMOUNT = (int) map.get("NODE_AMOUNT");
            CLIENT_PORT = (int) map.get("CLIENT_PORT");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
